package com.winning.joiner.magiccube.common.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.github.pagehelper.PageHelper;
import com.winning.joiner.magiccube.common.page.PageDomain;
import com.winning.joiner.magiccube.common.page.TableSupport;
import com.winning.joiner.magiccube.common.utils.ServletUtils;

public class BaseController {
	
	
	/**
     * 
     * getRequest:获取当前请求的request对象. <br/> 
     * @author lishang 
     * @return
     */
    public HttpServletRequest getRequest() {
        return ServletUtils.getRequest();
    }
    /**
     * 
     * getSession:获取session信息. <br/> 
     * @author lishang 
     * @return
     */
    public HttpSession getSession() {
        return getRequest().getSession();
    }
    

    /**
     * 设置请求分页数据
     */
    protected void startPage()
    {
        PageDomain pageDomain = TableSupport.buildPageRequest();
        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();
        if (null!=pageNum && null!=pageSize)
        {
            String orderBy = pageDomain.getOrderBy();
            PageHelper.startPage(pageNum, pageSize,orderBy);
        }
    }
    
    /**
     * 设置请求分页数据
     */
    protected void startPageNoOrder()
    {
        PageDomain pageDomain = TableSupport.buildPageRequest();
        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();
        if (null!=pageNum && null!=pageSize)
        {
            PageHelper.startPage(pageNum, pageSize);
        }
    }
    
    
     

	
	
}
